import java.net.*;

import java.util.*;

import java.sql.*;

public class Server_Main {

 public static void main(String[] args) {
 Scanner scanner=new Scanner(System.in);

  Thread readData;

  ReceiveLetterForClient receiver=new ReceiveLetterForClient();

  try{    readData =new Thread(receiver);

   readData.start(); 

  byte [] buffer=new byte[1];    

InetAddress address=InetAddress.getByName("127.0.0.1");  

  DatagramPacket dataPack=new DatagramPacket(buffer,buffer.length,address,888);

   DatagramSocket postman=new DatagramSocket();  

  System.out.print("请输入给客户端发送到消息：");  

  while(scanner.hasNext()){     String mess=scanner.nextLine();     

buffer =mess.getBytes();
  
   if(mess.length()==0)      System.exit(0);  

   buffer =mess.getBytes();  

   dataPack.setData(buffer);  

   postman.send(dataPack);  

   System.out.print("继续输入发给客户端的消息：");    }   }

  catch(Exception e){    System.out.println("客户端已断开"+e);   }

    }

}